fix(milestones): robust async loading state machine (#1099) - #1143
Open
Simultech369 wants to merge 1 commit into
Open
fix(milestones): robust async loading state machine (#1099)#1143Simultech369 wants to merge 1 commit into
Simultech369 wants to merge 1 commit into
Conversation
Closes Talenttrust#1099 - Refactored `MilestonesPage` state to an explicit discriminated union (`MilestonesFetchState`: `loading` | `empty` | `error` | `success`). - Made the initial repository load synchronous to prevent test breakage and layout flashes, while keeping the `loading` state available for explicit refetches/retries. - Used early returns instead of nested ternaries to ensure mutually exclusive rendering, preventing the `MilestonesBoardSkeleton`'s padding from doubling up inside `MilestonesContent`. - Fixed the accessibility issue by moving the screen-reader `aria-live` announcer to be unconditionally rendered at the top of the component, providing accurate status strings ("5 milestones found", "Loading...", etc). - Added new integration tests (`fetch-machine.test.tsx`) asserting all states in the state machine. - Ensured all existing unit and integration tests pass cleanly without requiring mass refactoring.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Closes #1099
This PR refactors the Milestones board data loading to use a robust, explicit discriminated union state machine, completely separating the
loading,empty,error, andsuccessstates.Key Improvements:
MilestonesFetchStatetype.if (fetchState.status === 'loading') return <MilestonesBoardSkeleton />;), we guarantee that states are mutually exclusive by construction. This inherently prevents the layout bug where the loader's container padding doubled up inside the page container.localStorageremains synchronous (matching the approach inContractsPage). Theloadingstate correctly yields a microtask on explicit refetch/retry.aria-liveannouncer into acommonHeaderblock so it is always present, reliably announcing state transitions ("Unable to load milestones", "No milestones tracked", "5 milestones found").src/app/milestones/__tests__/fetch-machine.test.tsxto explicitly test all 4 states of the machine.Everything is now robust, fully typed, and cleanly isolated.